<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <link rel="shortcut icon" href="favicon.ico"> <link href="./src/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="./src/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="./src/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="./src/css/animate.css" rel="stylesheet">
    <link href="./src/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="./src/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    </head>
    <body>
                                   <div class="ibox-content">
                        <form class="form-horizontal">
                            <input type="hidden" name="m" value="index">
                            <input type="hidden" name="a" value="sendsingle">
                            <div class="form-group">
                                <label class="col-sm-1 control-label" style="width: 100px;">当前状态：</label>

                                <div class="col-sm-2">
                                        <select class="form-control m-b" name="status" style="padding-top:2px;">
                                        <option value='0'>全部</option>
                                        <option value='1' <?php echo ($this->status == 1) ? 'selected' : '' ?> >激活</option>
                                        <option value='2' <?php echo ($this->status == 2) ? 'selected' : '' ?> >休眠</option>
                                    </select>
                                </div>
                                  <div class="col-sm-8">
                                    <button class="btn btn-sm btn-info" type="submit">搜索</button>
                                </div>
                            </div>
                        </form>
                    </div>
         <div class="row">
                <div class="ibox float-e-margins" style="width:98%;margin-left:1%;">
                    <div class="ibox-title">
                        <button class="btn btn-success " style="margin-top:-10px;" type="button" data-toggle="modal" data-target="#myModal5"><span class="bold">新增</span></button>    
                        <div style="display: none;"><button class="btn btn-success " style="margin-top:-10px;" type="button" data-toggle="modal" data-target="#myModal6" id="update"><span class="bold">修改</span></button></div>   
                        <button class="btn btn-success " style="margin-top:-10px;" type="button" id="toupdate"><span class="bold">修改</span></button> 
                        <button class="btn btn-success " style="margin-top:-10px;" type="button" id="delete"><span class="bold">删除</span></button>   
                    <button class="btn btn-success " style="margin-top:-10px;" type="button" id="dormancy"><span class="bold">休眠</span></button>    
                    <button class="btn btn-success " style="margin-top:-10px;" type="button" id="activation"><span class="bold">激活</span></button>  
                    </div>
                    <div class="ibox-content">

                        <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>名称</th>
                                    <th>编号</th>
                                    <th>当前状态</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach($this->data as $k=>$v){ ?>
                                <tr>
                            <input type="hidden" value="<?php echo $v['id'] ?>">
                                       <td><?php echo $v['id'] ?></td>
                                    <td><?php echo $v['name'] ?></td>
                                    <td><?php echo $v['describe'] ?></td>
                                    <td><?php echo ($v['status'] == 1) ? '激活':'休眠' ?></td>
                                </tr>
                                <?php } ?>
                            </tbody>
                        </table>

                    </div>
                </div>
            </div>
        	<div class="admin-table-page" style="margin-left:20px;">
				<div id="page" class="page">
				   <?php echo $this->paging;?>
				</div>
			</div>

     <div class="modal inmodal fade" id="myModal5" tabindex="-1" role="dialog"  aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                        <h4 class="modal-title">寄单点信息</h4>
                    </div>
                    <div class="modal-body">
                                    <form class="form-horizontal">
                            <div class="form-group">
                                                                
                                 <label class="col-sm-2 control-label">名称：</label>
                                  <div class="col-sm-3">
                                        <input class="form-control m-b" id="name" name="account" ">
                                </div>
                                <label class="col-sm-2 control-label">地区编号：</label>
                                <div class="col-sm-3">
                                        <input class="form-control m-b" id="describe" name="account">
                                </div>
                            </div>
                        </form>
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-white" id="gb" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" id="baocun">保存</button>
                    </div>
                </div>
            </div>
        </div>
        
             <div class="modal inmodal fade" id="myModal6" tabindex="-1" role="dialog"  aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                        <h4 class="modal-title">寄单点信息修改</h4>
                    </div>
                    <div class="modal-body">
                                    <form class="form-horizontal">
                            <div class="form-group">
                                                                
                                 <label class="col-sm-2 control-label">名称：</label>
                                  <div class="col-sm-3">
                                        <input class="form-control m-b" id="uname" name="account" ">
                                </div>
                                <label class="col-sm-2 control-label">地区编号：</label>
                                <div class="col-sm-3">
                                        <input class="form-control m-b" id="udescribe" name="account">
                                </div>
                            </div>
                        </form>
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-white" id="gb" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" id="ubaocun">保存</button>
                    </div>
                </div>
            </div>
        </div>
            <script src="./src/js/jquery.min.js?v=2.1.4"></script>
    <script src="./src/js/bootstrap.min.js?v=3.3.6"></script>



    <!-- 自定义js -->
    <script src="./src/js/content.js?v=1.0.0"></script>
    <script src="./src/js/plugins/sweetalert/sweetalert.min.js"></script>
<script>
    $(function(){
//        $("#baocun").click(function(){
//        });
$("tr:gt(0)").click(function(){
    ID = $(this).find("input").val();
    $("tr").removeClass("bkcl");
   $(this).addClass("bkcl");
});
            $('#baocun').click(function () {
                var describe = $("#describe").val();
                var name = $("#name").val();
                $.post("./?m=index&a=dosendsingle",{name:name,describe:describe},function(result){
                          if(result > 0){
                swal({
                    title: "提交数据成功",
                    text: "Submit data successfully"
                },function(){
                    location.href = "./?m=index&a=SendSingle";
                })
            }else{
                  swal({
                    title: "提交数据失败",
                    text: "Failed to submit data"
                });
            }
                });
          
            });
            

    $("#toupdate").click(function(){
        if(ID){
           $.get("./?m=index&a=sendsingleupdate&id="+ID,function(data){
                 data = eval("(" + data + ")");
                 theid = data['id'];
                 $("#uname").val(data['name']);
                 $("#udescribe").val(data['describe']);
           })
          // return false;
        $("#update").click();
        }
    });
    
                $('#ubaocun').click(function () {
                    
                var udescribe = $("#udescribe").val();
                var uname = $("#uname").val();
                $.post("./?m=index&a=dosendsingleupdate",{name:uname,describe:udescribe,id:theid},function(result){
                          if(result > 0){
                swal({
                    title: "数据修改成功",
                    text: "Data modification success"
                },function(){
                    location.href = "./?m=index&a=SendSingle";
                })
            }else{
                   swal({
                    title: "数据修改失败",
                    text: "Data modification failed"
                });
            }
                });
          
            });
            
            
                                            $("#dormancy").click(function() {
                    if (ID) {
                        $.get("./?m=index&a=sendsingledormancy&id=" + ID, function(result) {
                            if (result > 0) {
                                swal({
                                    title: "休眠成功",
                                    text: "dormancy is ok"
                                }, function() {
                                    location.href = "./?m=index&a=sendsingle";
                                });
                            }
                        });
                    }
                });
                $("#activation").click(function() {
                    if (ID) {
                        $.get("./?m=index&a=sendsingleactivation&id=" + ID, function(result) {
                            if (result > 0) {
                                swal({
                                    title: "激活成功",
                                    text: "activation is ok"
                                }, function() {
                                    location.href = "./?m=index&a=sendsingle";
                                });
                            }
                        });
                    }
                });
            
            $('#delete').click(function () {
                if(ID){
                    
        }else{
            return false;
        }
    swal({
        title: "您确定要删除这条信息吗",
        text: "请谨慎操作！",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "删除",
         cancelButtonText: "取消",
        closeOnConfirm: false
    }, function () {
               $.get("./?m=index&a=sendsingledelete&id="+ID,function(result){
            if(result){
                      swal({
                    title: "成功删除",
                    text: "这条数据将不会出在页面中显示",
                    type: "success",
                },function(){
                    location.href = "./?m=index&a=SendSingle";
                });
            }else{
                      swal({
                    title: "删除失败",
                    type: "error",
                });
            }
        });
  
    });
});
});
</script>
    </body>
</html>
